package jmu.cze.service.impl;

import jmu.cze.mapper.AircraftModelMapper;
import jmu.cze.mapper.FlightMapper;
import jmu.cze.mapper.TerminalMapper;
import jmu.cze.pojo.AircraftModel;
import jmu.cze.pojo.Flight;
import jmu.cze.service.FlightService;
import jmu.cze.vo.Terminal;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class FlightServiceImpl implements FlightService {
    private TerminalMapper terminalMapper;
    private AircraftModelMapper aircraftModelMapper;
    private FlightMapper flightMapper;


    @Resource(name = "terminalMapper")
    public void setTerminalMapper(TerminalMapper terminalMapper) {
        this.terminalMapper = terminalMapper;
    }

    @Resource(name = "aircraftModelMapper")
    public void setAircraftModelMapper(AircraftModelMapper aircraftModelMapper) {
        this.aircraftModelMapper = aircraftModelMapper;
    }

    @Resource(name = "flightMapper")
    public void setFlightMapper(FlightMapper flightMapper) {
        this.flightMapper = flightMapper;
    }

    @Override
    public Map<Integer, Terminal> selectAllTerminals() {
        return terminalMapper.selectAll();
    }

    @Override
    public boolean deleteAircraftModelByID(int modelID) {
        return aircraftModelMapper.deleteByID(modelID) == 1;
    }

    @Override
    public boolean insertAircraftModel(AircraftModel aircraftModel) {
        return aircraftModelMapper.insert(aircraftModel) == 1;
    }

    @Override
    public boolean updateAircraftModel(AircraftModel aircraftModel) {
        return aircraftModelMapper.update(aircraftModel) == 1;
    }

    @Override
    public Map<Integer, AircraftModel> selectAllAircraftModels() {
        return aircraftModelMapper.selectAll();
    }

    @Override
    public boolean deleteFlightByID(int flightID) {
        return flightMapper.deleteByID(flightID) == 1;
    }

    @Override
    public boolean insertFlight(Flight flight) {
        return flightMapper.insert(flight) == 1;
    }

    @Override
    public List<Flight> selectAllFlights() {
        return flightMapper.selectAll();
    }

    @Override
    public boolean updateFlight(Flight flight) {
        return flightMapper.update(flight) == 1;
    }

}
